package com.i72.governance.service.bean;

import com.i72.governance.service.helper.NacosServiceHelper;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import java.util.Map;


public class ServiceNode {


    private String id;

    /**
     * ip
     */
    private String ip;

    /**
     * 端口
     */
    private Integer port;

    /**
     * 协议
     */
    private String protocol;


    /**
     * 环境
     */
    private String environment;

    /**
     * 其他数据
     */
    private Map<String,String> metadata;




    @Override
    public int hashCode() {
        if (!StringUtils.isEmpty(ip) && port != null) {
            return (ip + ":" + port).hashCode();
        } else {
            return new Object().hashCode();
        }
    }

    @Override
    public boolean equals(Object obj) {
        return this.hashCode() == obj.hashCode();
    }


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    public String getProtocol() {
        return protocol;
    }

    public void setProtocol(String protocol) {
        this.protocol = protocol;
    }


    public String getEnvironment() {
        return environment;
    }

    public void setEnvironment(String environment) {
        this.environment = environment;
    }


    public Map<String, String> getMetadata() {
        return metadata;
    }

    public void setMetadata(Map<String, String> metadata) {
        this.metadata = metadata;
    }
}
